package adapter;

import android.content.Context;
import android.graphics.Paint;
import android.support.annotation.Nullable;
import android.support.v7.widget.RecyclerView;
import android.widget.TextView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;

import java.util.List;

import bean.BuyClassTimeBean;
import bean.CourseraBean;
import student.andlei.com.student.R;

public class BuyClassTimeAdapter extends BaseQuickAdapter<BuyClassTimeBean,BaseViewHolder> {

    public Context context;
    public BuyClassTimeAdapter(Context context, int layoutResId, @Nullable List<BuyClassTimeBean> data) {
        super(layoutResId, data);
        this.context = context;
    }

    @Override
    protected void convert(BaseViewHolder helper, BuyClassTimeBean item) {
        TextView tv_oldmoney = helper.getView(R.id.tv_oldmoney);
        tv_oldmoney.setPaintFlags(Paint. STRIKE_THRU_TEXT_FLAG|Paint.ANTI_ALIAS_FLAG);
        helper.setText(R.id.tv_classtime_number,item.goods_name);
        helper.setText(R.id.tv_money,""+item.price);
        tv_oldmoney.setText(item.original_price);
        if(item.IsChecked == 1){
            helper.getView(R.id.layout_bg).setBackgroundResource(R.drawable.rect_rounded_border_and_fill_deep);
            tv_oldmoney.setTextColor(context.getResources().getColor(R.color.appstyletitlecolor));
            helper.setTextColor(R.id.tv_classtime_number,context.getResources().getColor(R.color.appstyletitlecolor));
            helper.setTextColor(R.id.tv_money,context.getResources().getColor(R.color.appstyletitlecolor));
        }else {
            helper.getView(R.id.layout_bg).setBackgroundResource(R.drawable.rect_rounded_border_and_fill);
            tv_oldmoney.setTextColor(context.getResources().getColor(R.color.text_oldmoney_changecolor));
            helper.setTextColor(R.id.tv_classtime_number,context.getResources().getColor(R.color.text_changecolor));
            helper.setTextColor(R.id.tv_money,context.getResources().getColor(R.color.text_changecolor));
        }
    }
}
